/**
 * @param {number[]} nums
 * @param {number} k
 * @return {number}
 */
var sumIndicesWithKSetBits = function(nums, k) {
    let sum = 0
    for(let i = 0; i < nums.length; i++) {
        let str = i.toString(2)
        let n = 0
        for(let j = 0; j < str.length; j++) {
            if(str.charAt(j) == "1") n++
        }
        if(n == k) sum += nums[i]
    }
    return sum
};
console.log(sumIndicesWithKSetBits([5, 10, 1, 5, 2], 1));